<?php

include "./lib/src/skey.php";

$images_url = base_url('images');
$uploads_url = base_url('uploads');
$admin_url = base_url('otakkanan');
$kirim_url = base_url('otakkiri');

$mapdir = "
	<a href='$admin_url/' class='taut'>Home</a> &gt; 
";

$menu = $this->uri->segment(3, "all");

switch($menu)
{
	case "baru":
		$mapdir .= " 
			<a href='$admin_url/bantuan' class='taut'>Pusat Bantuan</a>
			&gt; 
			<b>Tambah Baru</b>
		";

		$isipage = "
				<div id='content2'>
						<h3>Tambah Bantuan Baru</h3>
							<div class='isicontent2'>
							
							  <form id='FrmMasukan' action='$kirim_url/bantuanbaru' method='post' onsubmit='return validasi_bantuan(this)' enctype='multipart/form-data' >
								
									<table>
										<tbody>
											<tr>
												<td class='left'>Pertanyaan * </td>
												<td class='right'> <input name='nama' type='text' placeholder='Pertanyaan' required /> ?</td>
											</tr>
											<tr>
												<td class='left'>Kategori Bantuan * </td>
												<td class='right'> 
													<select name='tipe'>
														<option value='help' selected='selected'>Bantuan</option>
														<option value='faq'>FAQ</option>
													</select>
												</td>
											</tr>
											<tr>
												<td class='left'>Jawaban * </td>
												<td class='right'> <textarea id='deskripsi' cols='30' rows='5' placeholder='Jawaban' name='jawaban'>Jawabannya adalah</textarea></td>
											</tr>
											
											<tr>
												<td class='left'>&nbsp;</td>
												<td class='right'>Tanda Bintang (*) berarti Kolom wajib Diisi</td>
											</tr>
											<tr>
												<td class='left'> &nbsp; </td>
												<td class='right'><input type='submit' value='Tambah'> &nbsp; <input type='reset' value='Ulang'></td>
											</tr>
										
										</tbody>
									</table>
									
							  </form>
							</div>
							
						</div>
			";
		
	;
	break;
	
	case "edit":
		$mapdir .= "
			<a href='$admin_url/bantuan' class='taut'>Pusat Bantuan</a>
			&gt; 
			<b>Edit Bantuan</b>
		";
		
		$idb = $this->input->get('idb');
		$hasil = $this->adminmodel->get_data_bantuan($idb);
		
		if($hasil !== FALSE)
		{
			foreach($hasil AS $hasil2)
			{
				$idb = $hasil2->idbantuan;
				$pertanyaan = html_escape($hasil2->pertanyaan);
				$jawaban = xss_clean($hasil2->jawaban);
				
				if($hasil2->tipe == 'help')
				{
					$tipe = "
						<option value='help' selected='selected'>Bantuan</option>
						<option value='faq'>Bantuan</option>
					";
				}
				else{
					$tipe = "
						<option value='help'>Bantuan</option>
						<option value='faq' selected='selected'>Bantuan</option>
					";
				}
				
				$tampil = "
							<tr>
								<td class='left'>Tipe * </td>
								<td class='right'> 
									<select name='tipe'>
										$tipe
									</select>
								</td>
							</tr>
							
							<tr>
								<td class='left'>Pertanyaan *</td>
								<td class='right'> <input name='pertanyaan' type='text' value='$pertanyaan' required /> ?</td>
							</tr>
							<tr>
								<td class='left'>Jawaban * </td>
								<td class='right'> <textarea cols='30' rows='5' id='deskripsi' name='jawaban'>$jawaban</textarea></td>
							</tr>
							<tr>
								<td class='left'>status * </td>
								<td class='right'>
									<select name='status'>
										<option value='1' selected='selected'>Aktif</option>
										<option value='0'>Non-Aktif</option>
									</select>
								</td>
							</tr>
							
							<tr>
								<td class='left'>&nbsp;</td>
								<td class='right'>Tanda Bintang (*) berarti Kolom wajib Diisi</td>
							</tr>
							<tr>
								<td class='left'> &nbsp; </td>
								<td class='right'><input type='hidden' name='idb' value='$idb' />
								<input type='submit' value='Ubah'> &nbsp; <input type='reset' value='Ulang'></td>
							</tr>";
			}
		}else{
			$tampil = "<tr>
							<td class='left'>&nbsp;</td>
							<td class='right'>Data Tidak Ditemukan</td>
						</tr>";
		}
		
		$isipage = "
				<div id='content2'>
						<h3>Edit Bantuan</h3>
							<div class='isicontent2'>
							
							  <form id='FrmMasukan' action='$kirim_url/updatebantuan' method='post' onsubmit='return validasi_bantuan(this)' enctype='multipart/form-data' >
								
									<table>
										<tbody>
										
											$tampil
										
										</tbody>
									</table>
									
							  </form>
							</div>
							
						</div>
			";
	;
	break;
	
	case "detail":
		$mapdir .= "
			<a href='$admin_url/bantuan' class='taut'>Pusat Bantuan</a>
			&gt; 
			<b>Detail</b>
		";
		
		$idb = $this->input->get('idb');
		$hasil = $this->adminmodel->get_data_bantuan($idb);
		
		if($hasil !== FALSE)
		{
			foreach($hasil AS $hasil2)
			{
				$idb = $hasil2->idbantuan;
				$pertanyaan = html_escape($hasil2->pertanyaan);
				$jawaban = xss_clean($hasil2->jawaban);
				
				if($hasil2->tipe == 'help')
				{
					$tipe = 'Bantuan';
				}
				else{
					$tipe = 'Pertanyaan sering ditanyakan (FAQ)';
				}
				
				if($hasil2->status == TRUE)
				{
					$status = "Aktif (<a href='$kirim_url/suspendbantuan'>Non-aktifkan</a>)";
				}
				else{
					$status = "Non-Aktif (<a href='$kirim_url/suspendbantuan?act=open'>Aktifkan</a>)";
				}
								
				$tampil = "
						<tr>
							<td class='left'>Tipe</td>
							<td class='right'> $tipe </td>
						</tr>
						<tr>
							<td class='left'>Pertanyaan</td>
							<td class='right'> $pertanyaan ?</td>
						</tr>
						<tr>
							<td class='left'>Jawaban</td>
							<td class='right'> $jawaban </td>
						</tr>
						
						<tr>
							<td class='left'>Status</td>
							<td class='right'>$status</td>
						</tr>
						
						<tr>
							<td class='left'>&nbsp;</td>
							<td class='right'>&nbsp;</td>
						</tr>
						<tr>
							<td class='left'> &nbsp; </td>
							<td class='right'><a href='$admin_url/bantuan' class='taut'>&lt;&lt; Kembali</a></td>
						</tr>";
			}
		}else{
			$tampil = "<tr>
							<td class='left'>&nbsp;</td>
							<td class='right'>Data Tidak Ditemukan</td>
						</tr>";
		}
		
		$isipage = "
				<div id='content2'>
					<h3>Detail Perusahaan</h3>
						<div class='isicontent2'>
						
							<table>
								<tbody>
								
									$tampil
								
								</tbody>
							</table>
								
						</div>
				 </div>
			";
	;
	break;
	
	default:
	
		$mapdir .= "
			<b>Pusat Bantuan</b>
		";
		
		$awal = $this->input->get('awal');
		$bantuan = $this->adminmodel->get_bantuan($awal);
		$databantuan = "";
		
		if($bantuan !== FALSE)
		{
			foreach($bantuan AS $bdata)
			{
				$idb = $bdata->idbantuan;
				$pertanyaan = word_limiter($bdata->pertanyaan, 20);
				
				
				$databantuan .= "
					<tr>
						<td class='left'>$pertanyaan </td>
						<td class='right'> 
						<a href='$admin_url/bantuan/detail?idb=$idb'>Detail</a> | 
						<a href='$admin_url/bantuan/edit?idb=$idb' class='taut'>Edit</a> |  
						<a href='$kirim_url/hapusbantuan?idb=$idb' onclick='return konfirmhapus()' title='Menghapus data bantuan dari database'>Hapus</a>
						</td>
					</tr>";
					
				
			}
		}else{
			$databantuan .= "<tr><td class='left'>&nbsp;</td><td class='right'>Belum ada data. <a href='$admin_url/bantuan/baru' class='taut'>Tambah?</a></td></tr>";
		}
		
		$config['base_url'] = $admin_url.'/bantuan?tanya=jawab';
		$config['total_rows'] = $this->adminmodel->hitung_data('idbantuan','dn_help');
		$config['per_page'] = 10; 
		$config['anchor_class'] = 'class="taut"';
		$config['page_query_string'] = TRUE;
		$config['query_string_segment'] = 'awal';

		$this->pagination->initialize($config); 
		$halaman = $this->pagination->create_links();
		
		$isipage = "
				<div id='content2'>
						<h3>Daftar Perusahaan</h3>
							<div class='isicontent2'>
							 <table>
								<tbody>
									<tr><td class='left'><a href='$admin_url/bantuan/baru' class='taut'>Tambah Baru</a></td><td class='right'>&nbsp;</td></tr>
									<tr><td class='left'>&nbsp;</td><td class='right'>&nbsp;</td></tr>
									$databantuan
									<tr><td class='left'>&nbsp;</td><td class='right'>&nbsp;</td></tr>
									<tr><td class='left'><a href='$admin_url/bantuan/baru' class='taut'>Tambah Baru</a></td><td class='right'>$halaman</td></tr>
								</tbody>
							 </table>
							</div>
							
					</div>
			";
	;
	break;
}

$data['map_dir'] = $mapdir;
$data['isi_page'] = $isipage;
$data['site_title'] = 'Bantuan - Dadan Network';
$data['base_url'] = base_url();
$data['tahun_sekarang'] = date("Y");

$this->parser->parse('template/admin', $data);


/* End of file perusahan.php */
/* Location: ./application/views/admin/perusahaan.php */
